import pandas as pd
from persistence import sqlUtil

'''
转化数据库日志表为csv，文件读取速度快且方便处理。
'''
def convert_db_csv():
    db_name = 'kw_cpt_user'
    conn, cur = sqlUtil.get_cur(db_name)
    sql = 'select * from history_2011_12_30;'
    df = pd.read_sql(sql, conn)
    df.to_csv(path_or_buf='../static/history_2011_12_30.csv', header=False, index=False)

if __name__ == '__main__':
    convert_db_csv()